<?php
//删除php 链接数据库
include('./connect.php');
//接收前端js传过来的Id
$Id = $_GET['Id'];
//写删除语句 需要前端传值 Id 才能在数据库找到并删除 
$sql = "delete from fruit where Id=$Id";
//执行这条语句
$res=mysql_query($sql);
//根据接口文档返回数据
if($res){
    $resp =array(
        "code"=>200,
        "body"=>array(
            "msg"=>"删除成功！"
        )
    );
    // echo encode_json($resp);json_encode($resp)
    echo json_encode($resp);
}else{
    $resp = array(
        "code"=>201,
        "body"=>array(
            "msg"=>"网络错误，请重试"
        )
        );
        echo json_encode($resp);
}
// 熊哥php
// include('./connect.php');

//   $id = $_GET['Id'];

//   $sql = "delete from fruit where Id=$id";

//   $res = mysql_query($sql);

//   if ($res) {
//     echo json_encode(array(
//       "code" => 200,
//       "body" => array(
//         "msg" => '删除成功'
//       )
//     ));
//   } else {
//     echo json_encode(array(
//       "code" => 201,
//       "body" => array(
//         "msg" => '网络错误，请重试'
//       )
//     ));
//   }
?>